package cn.itsource.org.service.impl;

import cn.itsource.basic.service.impl.BaseServiceImpl;
import cn.itsource.basic.util.PageList;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.mapper.EmployeeMapper;
import cn.itsource.org.query.EmployeeQuery;
import cn.itsource.org.service.IEmployeeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: ZHl
 * @Date: 2022-09-11 14:35
 */
@Service
public class EmployeeServiceImpl extends BaseServiceImpl<Employee,EmployeeQuery> implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;


    @Override
    public PageList<Employee> pageList(EmployeeQuery employeeQuery) {
        PageHelper.startPage(employeeQuery.getCurrentPage(), employeeQuery.getPageSize());
        List<Employee> employees = employeeMapper.pageList(employeeQuery);

        PageInfo<Employee> pageInfo = new PageInfo<>(employees);
        PageList<Employee> pageList = new PageList<>(pageInfo.getTotal(), pageInfo.getList());
        return pageList;
    }

    @Override
    public List<Employee> findAllManager() {
        return employeeMapper.findAllManager();
    }


}
